*reworks national income data.  

*In nov the sep data would be known by voters.  
*CHANGE FROM QUARTER IN QUESTION FROM THE QUARTER BEFORE IN FOLLOWING TABLE
*July-aug-sep quarter (weight of 4): don’t have
*April-may-june quarter (weight of 3): have first month of, so downweight to a weight of 1.  
*Jan-feb-mar quarter (weight of 2)
*Oct-nov-dec quarter (weight of 1)
*July-aug-sep quarter
*The above means keep July of odd numbered years through April of even numbered years for this run.  Other months should be dropped.  

clear
version 15.1
set varabbrev off, permanently

cd C:\Users\User\Dropbox\08_FORECAST\NationalVars\Batch20181029

import delimited 001_PersonalIncomeNatMonthly20181029.csv

keep if v1=="Line"|v1=="39"
drop v1 v2
sxpose, clear
destring _var1, gen(year)

gen month=.
local months JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
forvalues i=1/12 {
local a: word `i' of `months'
replace month=`i' if _var2=="`a'"
}
destring _var3, gen(income1)

gen even=1-(mod(year,2))
*change to the following row is necessary depending on the month.  Put the number of the last month included in even years after "month>".  
drop if month>9&even==1
*the early months of odd numbered years shouldn't be dropped because they create a buffer between quarters.  

recode month (1/3=1) (4/6=2) (7/9=3) (10/12=4), gen(quar)
collapse (mean) income1, by(even year quar)

gen yearquar=(year*10)+quar
tsset yearquar
gen lag=income1[_n-1]
gen chg1=(income1/lag)
*Annualize the changes, so what the changes represent are more intuitive.
replace chg1=chg1^4
gen chg2=chg1[_n-1]
gen chg3=chg1[_n-2]
gen chg4=chg1[_n-3]

*Since there are no partial quarters, there won't be downweighting because of that.  
gen income=[(chg1*4)+(chg2*3)+(chg3*2)+chg4]/10
*This is currently expressed as the quarterly growth rate, not the annual growth rate.  

keep if even==1&quar==3

keep year income
drop if year<1964

save 003income20181029, replace



